#!/bin/sh

# 确保应用目录存在且有权限
mkdir -p /app/uploads /app/results /app/logs
chmod -R 755 /app/uploads /app/results /app/logs

# 获取命令行参数
HOST="${APP_HOST:-0.0.0.0}"
PORT="${APP_PORT:-5000}"
DEBUG_FLAG=""

# 如果环境变量APP_DEBUG为true，则添加debug标志
if [ "${APP_DEBUG}" = "true" ]; then
  DEBUG_FLAG="--debug"
fi

# 输出启动信息
echo "Starting Word Compare application..."
echo "Host: $HOST"
echo "Port: $PORT"
echo "Debug: ${APP_DEBUG:-false}"

# 启动应用
exec python main.py --host="$HOST" --port="$PORT" $DEBUG_FLAG 